fix(readonly): enable MOVE rollback when folder is read-only
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 7 May 2025 12:37:43 +0000 (14:37 +0200)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Mon, 2 Jun 2025 10:40:18 +0000 (12:40 +0200)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/propagateremotemove.cpp

index 34c172bd3d49209ae93a1d32761f85bad61df70d..63078c69799fe133130cf296e1ad067918dd54ae 100644 (file)
@@ -209,7 +209,9 @@ void PropagateRemoteMove::slotMoveJobFinished()
             &propagator()->_anotherSyncNeeded);
         const auto filePath = propagator()->fullLocalPath(_item->_renameTarget);
         const auto filePathOriginal = propagator()->fullLocalPath(_item->_originalFile);
+        const auto oldFile = QFileInfo{filePathOriginal};
         QFile file(filePath);
+        auto permissionsHandler = FileSystem::FilePermissionsRestore{oldFile.absolutePath(), FileSystem::FolderPermissions::ReadWrite};
         if (!file.rename(filePathOriginal)) {
             qCWarning(lcPropagateRemoteMove) << "Could not MOVE file" << filePathOriginal << " to" << filePath
                                              << " with error:" << _job->errorString() << " and failed to restore it !";